﻿//JumbotCms_4.1 Final
using System;
using System.Data;
using System.IO;
using System.Web;
using System.Web.UI.WebControls;
using JumbotCms.Common;
namespace JumbotCms.WebFile.Admin
{
    public partial class _searchform : JumbotCms.API.AdminCenter
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            ChannelId = Str2Str(q("ccid"));
            id = Str2Str(q("id"));
            Admin_Load("", "html", true);
            string ClassId = Str2Str(q("cid"));
            if (!Page.IsPostBack)
            {
                if (q("k") != "")
                    this.txtKeyword.Text = q("k");
                if (ddlKeyClass.Items.Count < 1)
                {
                    doh.Reset();
                    doh.SqlCmd = "SELECT ID,Title,[Code] FROM [jcms_normal_class] WHERE [IsOut]=0 AND [ChannelId]=" + ChannelId + " ORDER BY code";
                    DataTable dtClass = doh.GetDataTable();
                    this.ddlKeyClass.Items.Clear();
                    this.ddlKeyClass.Items.Add(new ListItem("不指定栏目", "0"));
                    ListItem li;
                    for (int i = 0; i < dtClass.Rows.Count; i++)
                    {
                        li = new ListItem();
                        li.Value = dtClass.Rows[i]["Id"].ToString();
                        li.Text = getListName(dtClass.Rows[i]["Title"].ToString(), dtClass.Rows[i]["code"].ToString());
                        if (ClassId == li.Value)
                            li.Selected = true;
                        else
                            li.Selected = false;
                        this.ddlKeyClass.Items.Add(li);
                    }
                    dtClass.Clear();
                    dtClass.Dispose();
                }
                doh.Reset();
                doh.SqlCmd = "SELECT [SearchFieldValues],[SearchFieldTexts] FROM [jcms_normal_modules] WHERE [Type]='" + ChannelType + "' AND [Enabled]=1 ORDER BY pId";
                DataTable dtModule = doh.GetDataTable();
                this.ddlKeyType.Items.Clear();
                this.ddlKeyType.Items.Add(new ListItem("请选择", ""));
                ListItem li2;
                string _SearchValues = dtModule.Rows[0]["SearchFieldValues"].ToString();
                string _SearchTexts = dtModule.Rows[0]["SearchFieldTexts"].ToString();
                string[] _SearchValue = _SearchValues.Split(',');
                string[] _SearchText = _SearchTexts.Split(',');
                dtModule.Clear();
                dtModule.Dispose();
                for (int i = 0; i < _SearchValue.Length; i++)
                {
                    li2 = new ListItem();
                    li2.Value = _SearchValue[i];
                    li2.Text = _SearchText[i];
                    if (q("f") != "")
                    {
                        if (q("f") == li2.Value)
                            li2.Selected = true;
                        else
                            li2.Selected = false;
                    }
                    this.ddlKeyType.Items.Add(li2);
                }
                ListItem li3;
                string _StateValues = ",-1,0,1";
                string _StateTexts = "全部,已删,未审,已审";
                string[] _StateValue = _StateValues.Split(',');
                string[] _StateText = _StateTexts.Split(',');
                for (int i = 0; i < _StateValue.Length; i++)
                {
                    li3 = new ListItem();
                    li3.Value = _StateValue[i];
                    li3.Text = _StateText[i];
                    if (q("s") != "")
                    {
                        if (q("s") == li3.Value)
                            li3.Selected = true;
                        else
                            li3.Selected = false;
                    }
                    this.ddlState.Items.Add(li3);
                }

                if (q("d") != "")
                {
                    for (int i = 0; i < this.ddlAddDate.Items.Count; i++)
                    {
                        if (this.ddlAddDate.Items[i].Value == q("d"))
                            this.ddlAddDate.Items[i].Selected = true;
                    }
                }
            }

        }

    }
}
